/**
 * Statemachine example
 */
public class HelloFSM {

	public enum FSM {
		ONE {
			FSM fun(){
				System.out.println("One bootle of beer");
				return  TWO;
			}
		},
		TWO {
			FSM fun(){
				System.out.println( "Second bootle of beer");
				return HALT;
			}
		},
		HALT {
			FSM fun() {
				return HALT;
			}
		};
		
		abstract FSM fun();
	};
	
	public void run(){
		// Initial state
		FSM f = FSM.ONE;
		while(f.compareTo(FSM.HALT) != 0)
			f = f.fun();
	}
	
	public static void main(String argv[]){
		new HelloFSM().run();
	}
	
}
